package com.hl.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.entity.Secret;
import com.hl.sfzy.mapper.SecretMapper;
import com.hl.sfzy.service.SecretService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SecretServiceImpl implements SecretService {
	@Autowired
	private SecretMapper secretMapper;

	@Override
	public int add(Secret secret) {
		int add = secretMapper.Insert(secret);
		return add;
	}

	@Override
	public int edit(Secret secret) {
		int edit = secretMapper.Update(secret);
		return edit;
	}

	@Override
	public int remove(Integer secretId) {
		int remove = secretMapper.Delete(secretId);
		return remove;
	}

	@Override
	public int removeBatch(Integer[] secretIds) {
		int removeBatch = secretMapper.DeleteBatch(secretIds);
		return removeBatch;
	}

	@Override
	public List<Secret> find() {
		List<Secret> find = secretMapper.Select();
		return find;
	}

	@Override
	public PageInfo<Secret> findByPage(int pageNum, int pageSize, Secret secret) {
		PageHelper.startPage(pageNum,pageSize);
		List<Secret> secrets = secretMapper.Select(secret);
		PageInfo<Secret> pageInfo = new PageInfo<>(secrets);
		return pageInfo;
	}

	@Override
	public Secret findById(Integer secretId) {
		Secret findById = secretMapper.SelectById(secretId);
		return findById;
	}
}
